package edu.guet.server.controller;

import edu.guet.server.model.vo.ResourceVO;
import edu.guet.server.service.ShowResourceService;
import edu.guet.server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping
public class ShowResourceController {

    @Autowired
    private ShowResourceService resourceService;

    @GetMapping("/unit/showresource")
    public ResultAPI showResource(@RequestParam int unit_id){

        List<ResourceVO> resourceVO = resourceService.showResource(unit_id);
        if(resourceVO == null){
            return ResultAPI.error("未找到相应资源...");
        }
        return ResultAPI.success(resourceVO);
    }
}
